﻿@model GPS.ENTITYS.CrudModelDKH_LOP

@{
    ViewBag.Title = "Sửa lớp học";
}


@using (Html.BeginForm("EditClass", "GPS_LopHoc", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()


    @Html.ValidationSummary(true)
     <h3 class="text-center fdb-title-search-form">Sửa thông tin lớp học</h3>
    <div id="tabs">
        <div id="tabs-1">
            @Html.Hidden("IsEdit", 0)

            <fieldset class="fs_body">
                <legend class="head_title">Thông tin lớp học</legend>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Mã lớp học
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.KH_LOP_MA, new { @class = "form-control", @id = "KH_LOP_MA", @readonly = "readonly" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_MA)
                    </div>

                    <div class="col-md-2 control-label">
                        Tên lớp học
                    </div>
                    <div class="col-md-2">
                        @Html.TextBoxFor(model => model.KH_LOP_TEN, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_TEN)
                    </div>
                </div>


                <div class="row margin-top-05">
                    <div class="col-md-2 control-label text-left">
                        Đơn vị đào tạo
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.KH_LOP_DVGTVT_MA, new { @class = "form-control", @id = "KH_LOP_DVGTVT_MA", @style = "width:100%;max-width:100%;" })
                        <span id="rDataDVGTVT_MA" style="width:500px"></span>
                        @Html.ValidationMessageFor(model => model.KH_LOP_DVGTVT_MA)
                        <div class="help-tip">
                            <p>Gõ mã hoặc Tên Đơn vị  để hiển thị danh sách đơn vị </p>
                        </div>
                    </div>

                    <div class="col-md-2 control-label text-left">
                        Mã khóa học
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_KH_MA, (SelectList)ViewBag.DKH_MAs, string.Empty, new { @class = "form-control", @id = "ddlKH_LOP_KH_MA" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_KH_MA)
                    </div>

                   
                </div>


                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Hạng đào tạo
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_HANGDT_MA, (SelectList)ViewBag.HANGDT_MAs, string.Empty, new { @class = "form-control", @id = "ddlHANGDT_MA" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_HANGDT_MA)
                    </div>

                    <div class="col-md-2 control-label">
                        Hạng GPLX
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_HGPLX_MA, (SelectList)ViewBag.HANGGPLX_MAs, string.Empty, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_HGPLX_MA)
                    </div>
                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label text-left">
                        Giảng viên
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_GV_MA, (SelectList)ViewBag.DGV_MAs, string.Empty, new { @class = "form-control", @style = "width:300px", @id = "ddlDGV_MA" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_GV_MA)
                    </div>

                    <div class="col-md-2 control-label text-left">
                        Phương tiện
                    </div>
                    <div class="col-md-4">
                        @Html.DropDownListFor(model => model.KH_LOP_PT_MA, (SelectList)ViewBag.DPT_MAs, string.Empty, new { @class = "form-control", @style = "width:300px", @id = "ddlDPT_MA" })
                        @Html.ValidationMessageFor(model => model.KH_LOP_PT_MA)
                    </div>

                </div>

                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Ngày bắt đầu
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.KH_LOP_NGAYBD, "{0:dd/MM/yyyy}", new { @class = "form-control", @style = "width:120px" })

                    </div>
                    <div class="col-md-2 control-label">
                        Ngày kết thúc
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.KH_LOP_NGAYKT, "{0:dd/MM/yyyy}", new { @class = "form-control", @style = "width:120px" })
                    </div>
                </div>
                <div class="row margin-top-05">
                    <div class="col-md-2 control-label">
                        Tổng học viên
                    </div>
                    <div class="col-md-4">
                        @Html.TextBoxFor(model => model.KH_LOP_TONGHV, new { @class = "form-control", @style = "width:120px", @type = "number" })

                    </div>
                    <div class="col-md-2 control-label">
                        Trạng thái
                    </div>
                    <div class="col-md-4">
                        @Html.CheckBoxFor(model => model.KH_LOP_ACTIVE, new { @class = "checkbox" })
                    </div>
                </div>

                <div class="row margin-top-05">

                    <div class="col-md-2 control-label">
                        Mô tả
                    </div>
                    <div class="col-md-10">
                        @Html.TextAreaFor(model => model.KH_LOP_MOTA, new { @class = "form-group", @rows = 5, @style = "width:100%;max-width:100%;" })
                    </div>
                </div>
            </fieldset>
        </div>
    </div>
    <br />
    <div class="row">
        <div class="col-md-12">
            @*<input type="submit" value="Cập nhật" class="btn btn-info btn-sm" />*@
            <button type="submit" class="btn btn-danger btn-sm">
                <span class="glyphicon glyphicon-floppy-disk"></span> Cập nhật
            </button>
            &nbsp;&nbsp;
            @Html.ActionLink("Quay lại", "IndexClass", null, new { @class = "btn btn-primary btn-sm" })
        </div>

    </div>
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

<script src="~/Scripts/datepicker.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/jquery.maskMoney.js"></script>
<script src="~/Scripts/jquery.number.js"></script>
<script src="~/Scripts/jquery.masknumber.js"></script>
<script src="~/Scripts/moment.js"></script>

<script type="text/javascript">

    // Voi jQuery 1.9 > thi chi validate gia tri trong active tab
    // Muon validate nhung gia tri trong cac tab khac nua thi dung jquery.validate 1.8.1 or 1.7


    // mask edit cho truong ngay thang (su dung jquery.maskedinput)


    function ToJavaScriptDate(value) {
        if (value != null) {
            var pattern = /Date\(([^)]+)\)/;
            var results = pattern.exec(value);
            var dt = new Date(parseFloat(results[1]));
            return dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear();
        }
        return null;
    }
</script>
<script type="text/javascript">
    $("#KH_LOP_NGAYBD").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });

    $("#KH_LOP_NGAYKT").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });


    $("#KH_LOP_NGAYBD").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
    $("#KH_LOP_NGAYKT").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });

    // cho phep nhap so thap phan (su dung jquery.number)
    //$("#GV_THAMNIENLX").number(true, 2, '.', '');

</script>

@Styles.Render("~/Content/themes/base/css")

<script type="text/javascript">
    $(document).ready(function () {

          $("#KH_LOP_DVGTVT_MA").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/GPS_LopHoc/AutoCompleteDVGTVT_MA",
                    type: "POST",
                    dataType: "json",
                    data: { term: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.DVGTVT_TEN, value: item.DVGTVT_MA + ':' + item.DVGTVT_TEN };
                        }))


                    }
                })
            },
            change: function (event, ui) {
                var _val = $("#KH_LOP_DVGTVT_MA").val();
                if (_val != null && _val != '') {
                    $.ajax({
                        url: '@Url.Action("getKH_MAs", "GPS_LopHoc")',
                        type: 'post',
                        data: {
                            ma_DVGT: _val
                        }
                    }).done(function (response) {

                        // update KH
                        var a = '<option value></option>' + response;   // defaut value
                        $("#ddlKH_LOP_KH_MA").html(a);

                        var b = '<option value></option>' + response;   // defaut value
                        $("#KH_LOP_MA").html(b);

                    });
                }
            },
            messages: {
                noResults: "", results: ""
            }
        }).click(function () {
            $(this).val("");
            $(this).autocomplete("search");
        });



        @*$("#ddlDVGTVT_MA").change(function () {
            var _valKH = $('#ddlKH_LOP_KH_MA').val();
         //   alert(_valKH);
            if (_valKH != null && _valKH !='')
            {
                $.ajax({
                    url: '@Url.Action("getKH_LOP_MA", "GPS_LopHoc")',
                    type: 'post',
                    data: {
                        p_DVGTVT_MA: $('#ddlDVGTVT_MA').val(),
                        p_KH_LOP_KH_MA: _valKH
                    }
                }).done(function (response) {

                    $('#KH_LOP_MA').val(response);
                });
            }
            else
            {
                alert("Hãy nhập khóa học!");
            }

        });*@

        $("#ddlKH_LOP_KH_MA").change(function () {
            var _valKH = $('#KH_LOP_DVGTVT_MA').val();
            //   alert(_valKH);
            if (_valKH != null && _valKH != '') {
                $.ajax({
                    url: '@Url.Action("getKH_LOP_MA", "GPS_LopHoc")',
                    type: 'post',
                    data: {
                        p_DVGTVT_MA: _valKH,
                        p_KH_LOP_KH_MA:  $('#ddlKH_LOP_KH_MA').val()
                    }
                }).done(function (response) {

                    $('#KH_LOP_MA').val(response);
                });
            }
            else {
                alert("Hãy nhập đơn vị GTVT!");
            }

        });

        $("#ddlHANGDT_MA").change(function () {
            var _valDVGTVT = $('#KH_LOP_DVGTVT_MA').val();
            var _valHANGDT = $('#ddlHANGDT_MA').val();
            //   alert(_valKH);
            if (_valDVGTVT != null && _valDVGTVT != '') {
                $.ajax({
                    url: '@Url.Action("getDGV_HANGHT", "GPS_LopHoc")',
                    type: 'post',
                    data: {
                        p_HANGHT_MA: _valHANGDT,
                        p_DVGTVT_MA: _valDVGTVT
                    }
                }).done(function (response) {

                    var a = '<option value></option>' + response;   // defaut value
                    $("#ddlDGV_MA").html(a);
                });
            }
            else {
                alert("Hãy nhập đơn vị GTVT!");
            }

        });
    })
</script>
